C# 看下我的计算机代码哪出错了`!急`在线等!

来源:百度知道 编辑:UC知道 时间:2024/05/25 22:13:55
我现在要想做个计算器`实现+ - * /` 提示:是用web环境下写的代码!!
2个TextBox 1个DropDownList `1个Label1 `1个 Button`不是控制台From那种格式的!!!
protected void btnjjy_Click(object sender, EventArgs e)
{
double aay;
double zzy;

try
{
aay = Convert.ToDouble(txtyyc.Text.Trim());
zzy = Convert.ToDouble(txthhy.Text.Trim());
}
catch
{
txtyyc.Text = "";
lbloop.Text = "请输入数值";

txthhy.Text = "";
lbloop.Text = "请输入数值";
}
}

protected void ddlbce_SelectedIndexChanged(object sender, EventArgs e)
{

double aay = 0;
double zzy = 0;
lbloop.Text = ddlbce.Text.ToString();

switch (ddlbce.Text

你要在lblloop后加上.text,在最后的return要去掉,没有必要用return,因为这是个事件,你的程序要是这么该程序就通了,不过运行结果不对,我感觉你的swich那里应该是个方法,但你却写进事件里。是疏忽么??
我把你的程序改了,里面的控件名我变了,呵呵。参考下,我调过去啦
protected void btnjjy_Click(object sender, EventArgs e)
{
double aay;
double zzy;

try
{
aay = Convert.ToDouble(this.TextBox1.Text.Trim());
zzy = Convert.ToDouble(this.TextBox2.Text.Trim());
this.Label1.Text=method(aay, zzy);
}
catch
{
this.TextBox1.Text = "";
this.Label1.Text = "请输入数值";

this.TextBox2.Text = "";
this.Label1.Text = "请输入数值";
}

}

protected void ddlbce_SelectedIndexChanged(object sender, EventArgs e)
{

this.Label1.Text = this.DropDownList1.Text.ToString();

}
protected string method(double aay,double zzy)
{
string stMethod = "";
switch (thi